<?php
/**
 * @user: leo
 * @date: 2021/5/17
 * @createTime: 14:37
 * @company: 迈酷网络科技 http://www.maicooit.com
 */
namespace app\admin\model;

use think\Model;

class Project extends Model
{
    //列表
    public function ProjectListModel($key,$domain,$page,$pagesize){
        $field = ['p.id','p.project_name','p.project_no','p.project_level','p.iskey','p.reason','pc.name as project_class_name'];
        $list = $this->alias('p')
            ->where('domain','=',$domain)
            ->join('project_class pc','p.project_class=pc.id')
            ->field($field)
            ->paginate([
                'list_rows'=> $pagesize,
                'var_page' => 'page',
                'page'=>$page
            ])->each(function($item, $key){
                if($item['iskey'] ==  1) $item['cellClassName'] = ['project_name'=>'demo-table-info-cell-age'];
                return $item;
            });
        return $list;
    }
//cellClassName: {
//name: 'demo-table-info-cell-name'
//}
    //新增
    public function ProjectInsertModel($ProjectInfo){
        return $this->insertGetId($ProjectInfo);
    }
    //保存
    public function ProjectSaveModel($projectid,$ProjectInfo){
        $where[] = ['id','=',$projectid];
        $res = $this->where($where)->save($ProjectInfo);
        return $res;
    }
    //启用、禁用
    public function ProjectDisableEableModel($projectid){
        $where[] = ['id','=',$projectid];
        $data['status'] = -1;
        $res = $this->where($where)->save($data);
        return $res;
    }
    //删除
    public function ProjectdelModel($projectid){
        $where[] = ['id','=',$projectid];
        $res = $this->where($where)->delete();
        return $res;
    }
}
